﻿@model LeadVinaglue.Models.ViewPages.ProductManagementModel
           
@{
    ViewBag.Title = "Cập nhật tài liệu";
    Layout = "~/Views/Shared/_Layout.Management.cshtml";
}
<form method="post" class="form" action="/Management/ProductList/Edit/@ViewBag.ProductId">
	<fieldset id="apps">
		<h2 class="app">
	        <strong>Cập nhật tài liệu</strong>
        </h2>
		<div class="errorMessage" data-bind="visible: InvalidateForm" >
			<span class="error">Xin hãy nhập thông tin bên dưới chính xác.</span>
		</div>				
		<div class="title">
			<h3>Thông tin</h3>
		</div>
		
		<!-- Error messages -->
        <div id="errorMessages" style="display:none;">
			<span class="errorgrid">                            
            </span>
		</div>
        <div class="clear"></div>

        <div id="groupfields" class="panel grouped-form">
            <!-- Group 1 -->
            <ul id="tab1" class="accordeon-tabs accordeon-2">
                <li class="open">
                    <h3>Thông tin chung</h3>
                    <span class="panel">
                        <div class="col ident" style="width:450px">                        
                            <div class="row">
					            <label for="text1">Tiêu đề:</label>
					            <input class="text" type="text" style="width:350px" data-bind="value: Title, attr:{maxlength:250}" name="Title" />
				            </div>  
                            <div class="row">                        
					            <label for="text12">Danh mục:</label>
                            </div>  
                            <div class="row"> 
                                <div class="select-holder">
                                    <select class="select" name="CategoryID" data-bind="value: CategoryID, foreach: CategoryList">
                                        <option data-bind="value: ID, text: Name"></option>
                                    </select>
                                </div>
                            </div>
                            <div class="row">              
					            <label for="text12">Danh mục con:</label>
                            </div>  
                            <div class="row"> 
                                <div class="select-holder">                            
                                    <select class="select" id="SubCategoryID" name="SubCategoryID" data-bind="value: SubSelectedID, foreach: SubCategoryList">
                                        <option data-bind="value: ID, text: Name"></option> 
                                    </select>
                                </div>
                            </div>             
                            <div class="row">Mô tả</div>
                            <div class="row">
				                <textarea id="elm2" class="text" rows="7" style="width: 400px;" data-bind="value: LongDesc" name="LongDesc">
                                </textarea>
			                </div>
                        </div>
                        <div class="col">     
                            <div id="editform" class="row">
					            <label for="text12">Kích hoạt:</label>
                                <div class="groupinput" style="width: 400px">
                                    <input class="text" type="checkbox" data-bind="checked: Active" name="Active" />
                                </div>					    
				            </div>      
                            <div class="row">Ảnh đại diện (<= 100Kb)</div>
                            <div class="row">
                                <img alt="logo" data-bind="attr: {src: ImageUrl}" />
                                <input type="hidden" name="ImageUrl" data-bind="value: FileName" />
                            </div>  
                            <div class="row">
						        <input type="file" name="fileData" id="fileData" class="btn btn-choose-file"  />
					        </div>
                        </div>
                          
                        <div class="clear"></div>   
                    </span>
                </li>
                <li class="open">
                    <h3>Thông tin tài liệu đính kèm</h3>
                    <span class="panel">
                        <table class="tablegrid">
                            <thead>
                                <tr class="title">
                                    <th>Loại tài liệu</th>
                                    <th>Tên tài liệu</th>
                                    <th>Lượt xem</th>
                                    <th>Lượt download</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>@Model.ProductInfo.FileType</td>
                                    <td>@Model.ProductInfo.FileName</td>
                                    <td>@Model.ProductInfo.Reviewed</td>
                                    <td>@Model.ProductInfo.Downloaded</td>
                                </tr>
                            </tbody>
                        </table>
                    </span>
                </li>
            </ul>
        </div>

		<div class="foot-info">
			<h3 class="centered-wbtn centered-wbtn-bottom save">
  				<span>
  					<a class="btn btn-cancel-page" href="/Management/ProductList">previous</a>
					<input type="button" class="btn btn-submit-page" data-bind="click: SubmitForm" value="Submit" />
                </span>
			</h3>
		</div>
	</fieldset>
</form>
<script type="text/javascript">
    var data = @(Html.Raw(Json.Encode(Model)));
</script>
<script src="/Scripts/Product/EditProduct.js" type="text/javascript"></script>
<script src="/TinyMCE/tiny_mce.js" type="text/javascript"></script>
<script src="/TinyMCE/tinymce.init.js" type="text/javascript"></script>
<script src="/Scripts/Library/jquery.uploadify.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#fileData").uploadify({
            'multi': false,
            'buttonText': 'Upload Image',
            'buttonClass': 'btn btn-choose-file',
            'width': 98,
            'height': 35,
            'fileSizeLimit': '100KB',
            'swf': '/images/uploadify.swf',
            'fileTypeDesc': 'Flash',
            'fileTypeExts': '*.jpg; *.jpeg; *.png; *.gif',
            'uploader': '/Management/ProductList/Upload',
            'onUploadProgress': function (file) {
                // Disabler
                $('.waiting').remove();
                $('#apps').waiting();
                $('.waiting').show();
                $('#progress').css("display", "block");
            },
            'successTimeout': 180,
            'onUploadSuccess': function (file, data, response) {
                var data = jQuery.parseJSON(data);
                // Image url
                viewModel.ImageUrl(data.ImageUrl);
                viewModel.FileName(data.FileName);

                $('.waiting').hide();
                $('#progress').css("display", "none");
            }
        });
    });
</script>